home *** CD-ROM | disk | FTP | other *** search
- Path: news.dtc.hp.com!hplntx!hplabs!hp-pcd!hpcvca!jg
- From: jg@cv.hp.com (Joe Gilray)
- Newsgroups: comp.lang.c++
- Subject: Re: [Q] Errors using TArrayAsVector, "unable to find constructor". BC++ 4.5.
- Date: 18 Apr 1996 01:04:21 GMT
- Organization: Hewlett-Packard Company, Corvallis, Oregon USA
- Message-ID: <4l44el$62@hpcvca.cv.hp.com>
- References: <3170528B.7641@novell.com>
- NNTP-Posting-Host: hpcvcef.cv.hp.com
- X-Newsreader: TIN [version 1.2 021193BETA PL3]
-
- Max Norris (mnorris@novell.com) wrote:
- ....
-
- : template <class Type>
- : class Sorter:public TArrayAsVector<Type> {
- : private:
- : int temp;
- : public:
- : Sorter() {};
- : virtual void sort()=0;
- : int operator == (const Sorter& p) const
- : { return (p.temp==temp) ? 1:0; };
- : };
-
- Max,
-
- Each constructor must call construct its base classes by calling a base class
- constructor in its initialization list. If you don't explicitly say which
- constructor to use, the compiler will automatically insert a call to the
- base class's default (no-argument) ctor.
-
- This is what is going on in the ctor for Sorter, unfortunately Sorter's base
- class, TArrayAsVector<Type> doesn't have a default ctor. To remedy the problem
- put a call to the desired ctor in the initialization list of your Sorter
- ctor, something like this:
-
- Sorter() : TArrayAsVector<Type>(10) {}
-
- -Joe Gilray
-